<html>
<head><meta charset="utf-8"><title>Time limits during const-eval · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html">Time limits during const-eval</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="183307468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183307468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183307468">(Dec 12 2019 at 22:01)</a>:</h4>
<p>With  <code>if</code> available on nightly, and <code>loop</code> soon to follow, it's now feasible for users to write <code>const</code> initializers that will run for a noticeable amount of time. We should discuss if/how we want to limit the amount of time spent during const-eval by default. I described one possible configuration mechanism in <a href="https://github.com/rust-lang/rust/issues/67217" target="_blank" title="https://github.com/rust-lang/rust/issues/67217">#67217</a>, along with the set of defaults I would like to see.</p>



<a name="183307968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183307968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183307968">(Dec 12 2019 at 22:06)</a>:</h4>
<p>As I mention in the comments, I would like to have some way for the user to disable the infinite loop detector in the short-term, although I no longer think we need to block <a href="https://github.com/rust-lang/rust/issues/67216" target="_blank" title="https://github.com/rust-lang/rust/issues/67216">#67216</a> on it. It would be cool if we could decide on the interface for configuring time limits for const-eval relatively soon, and use that in the short-term to disable the loop detector, but it's not necessary. As I mentioned elsewhere, we could use a <code>-Z</code> flag for this temporarily.</p>



<a name="183308150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183308150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183308150">(Dec 12 2019 at 22:09)</a>:</h4>
<p>An alternative to a configurable limit is to have a fixed limit that controls a <code>long_running_const_eval</code> lint. If you allow the lint, the infinite loop detector is disabled, and no limits are imposed on const-eval. If the lint is set to warn (the default), a warning will appear after const-eval has run to the limit, and the infinite loop detector will start to trigger. If the lint is set to deny, reaching the fixed limit is a hard error.</p>



<a name="183447295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183447295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183447295">(Dec 14 2019 at 16:12)</a>:</h4>
<p>TBH, I am not convinced the snapshot-based infinite loop detector is a good idea. IMO something simple like a basic-block-counter should be sufficient. But I won't block people if they want to go overboard with design here. ;)</p>



<a name="183447310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183447310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183447310">(Dec 14 2019 at 16:13)</a>:</h4>
<p>However I'm afraid having both a fancy snapshot-based detector and a simple counter that interact in complex ways will be quite confusing.</p>



<a name="183447398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183447398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183447398">(Dec 14 2019 at 16:15)</a>:</h4>
<p>yea, I just thought the snapshot loop detector was a great idea for UX, but it's so much stuff for little gain...</p>



<a name="183447405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183447405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183447405">(Dec 14 2019 at 16:15)</a>:</h4>
<p>I'm fine with scrapping it</p>



<a name="183588492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/183588492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#183588492">(Dec 16 2019 at 20:42)</a>:</h4>
<p>I'm gonna open a PR removing the loop detector after <a href="https://github.com/rust-lang/rust/issues/67260" target="_blank" title="https://github.com/rust-lang/rust/issues/67260">#67260</a> gets merged.</p>



<a name="184067188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Time%20limits%20during%20const-eval/near/184067188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Time.20limits.20during.20const-eval.html#184067188">(Dec 22 2019 at 19:56)</a>:</h4>
<p>I think this is the right move, but I'm also feeling bad because you put so much work into it.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>